import { toLogin } from ".";

const defaultSession = 'B8ESeL9BbmERE6CIqSYs67%2F5pNweTWFepWMZegHrnXMnyTa0dDDi%2FizCWo8t%2Bdl%2F1nfFwDqBcRwSK3gNAYsqxq6kHvFzTAn5z0tuPFrifrawkivXZEHWVA7cVY2gpLK49ahHIAGG7dNjrtqOkzBbUQ%3D%3D';

const session = {
  id: null,
  load() {
	  this.id = uni.getStorageSync('sessionId');
	  return this.id
  },
  save(res) {
	  if (res.status == 1) {
		  uni.setStorageSync('sessionId', res.session_id);
		  this.id = res.session_id;
	  }
  },
  clear() {
	  uni.clearStorageSync('sessionId');
	  this.id = null;
  },
  check() {
	  if (!this.id) {
		  toLogin();
		  return true;
	  }
	  return false;
  }
};

export default session;